package com.binest.homePageSet.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.binest.common.annotation.Log;
import com.binest.common.core.controller.BaseController;
import com.binest.common.core.domain.AjaxResult;
import com.binest.common.enums.BusinessType;
import com.binest.homePageSet.domain.HomePageSet;
import com.binest.homePageSet.service.IHomePageSetService;
import com.binest.common.utils.poi.ExcelUtil;
import com.binest.common.core.page.TableDataInfo;

/**
 * 首页设置Controller
 * 
 * @author wwd
 * @date 2024-03-27
 */
@RestController
@RequestMapping("/homePageSet/homePageSet")
public class HomePageSetController extends BaseController
{
    @Autowired
    private IHomePageSetService homePageSetService;

    /**
     * 查询首页设置列表
     */
    @PreAuthorize("@ss.hasPermi('homePageSet:homePageSet:list')")
    @GetMapping("/list")
    public TableDataInfo list(HomePageSet homePageSet)
    {
        startPage();
        List<HomePageSet> list = homePageSetService.selectHomePageSetList(homePageSet);
        return getDataTable(list);
    }

    /**
     * 导出首页设置列表
     */
    @PreAuthorize("@ss.hasPermi('homePageSet:homePageSet:export')")
    @Log(title = "首页设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HomePageSet homePageSet)
    {
        List<HomePageSet> list = homePageSetService.selectHomePageSetList(homePageSet);
        ExcelUtil<HomePageSet> util = new ExcelUtil<HomePageSet>(HomePageSet.class);
        util.exportExcel(response, list, "首页设置数据");
    }

    /**
     * 获取首页设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('homePageSet:homePageSet:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(homePageSetService.selectHomePageSetById(id));
    }

    /**
     * 新增首页设置
     */
    @PreAuthorize("@ss.hasPermi('homePageSet:homePageSet:add')")
    @Log(title = "首页设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HomePageSet homePageSet)
    {
        return toAjax(homePageSetService.insertHomePageSet(homePageSet));
    }

    /**
     * 修改首页设置
     */
    @PreAuthorize("@ss.hasPermi('homePageSet:homePageSet:edit')")
    @Log(title = "首页设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HomePageSet homePageSet)
    {
        return toAjax(homePageSetService.updateHomePageSet(homePageSet));
    }

    /**
     * 删除首页设置
     */
    @PreAuthorize("@ss.hasPermi('homePageSet:homePageSet:remove')")
    @Log(title = "首页设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(homePageSetService.deleteHomePageSetByIds(ids));
    }
}
